/*=====================================================
Critical Links
Auto Configuration Server

Authors:
	Rui Eduardo Gouveia Gil - r-gil@critical-links.com

Date: 2010
Version 0.1
=======================================================*/
#ifndef __DEVICE_H__
#define __DEVICE_H__

#include <vector>
#include <string>
#include <iostream>
#include <rgcpp/tools/ToString.h>

#include "data/Command.h"

namespace acs
{

#define CPE_TIMEOUT 600

enum DeviceStatus
{
	DS_PENDING_VALIDATION,
	DS_PENDING_CONFIRMATION,
	DS_PENDING_BACKUP_WITH_SOUNDS,
	DS_PENDING_BACKUP,
	DS_PENDING_TASKS,
	DS_EXECUTING_BACKUP,
	DS_EXECUTING_TASKS,
	DS_SYNCHRONIZED,
	DS_OFFLINE
};

enum DeviceConfigMode
{
	DCM_AUTOMATIC_FIRST_CONFIG,
	DCM_AUTOMATIC_CONFIG,
	DCM_AUTOMATIC_CONFIG_IF_NO_CONFLICTS,
	DCM_MANUAL
};

class Device
{
	private:
		int id;
		int groupID;
		int configID;
		int lastRestoreConfigID;
		DeviceConfigMode configMode;

		DeviceStatus status;

		time_t updated;
		time_t creation;
		time_t contacted;

		time_t lastBackup;
		time_t lastRestore;
		time_t localChange;

		std::string ip;
		std::string SHA;
		std::string name;
		std::string description;
		std::string actionPeriod;
		std::string configFileName;
		std::vector<Command> commands;

		std::string build;
		std::string upTime;
		std::string release;
		std::string swapUsed;
		std::string maxUsers;
		std::string licenseID;
		std::string systemLoad;
		std::string guiVersion;
		std::string freeMemory;
		std::string firstConfig;
		std::string pepsVersion;
		std::string customerName;
		std::string partitionVar;
		std::string partitionRoot;
		std::string partitionHome;
		std::string installedMemory;
		std::string hardwareDescription;

	public:
		Device();
		~Device();

		void setID(const int id);
		int getID() const;

		void setGroupID(const int groupID);
		int getGroupID() const;

		void setConfigID(const int configID);
		int getConfigID() const;

		void setRestoreConfigID(const int lastRestoreConfigID);
		int getRestoreConfigID() const;

		void setConfigMode(DeviceConfigMode configMode);
		DeviceConfigMode getConfigMode() const;

		void setStatus(DeviceStatus status);
		DeviceStatus getStatus() const;
		std::string getStatusStr() const;
		std::string getStatusIcon() const;
		DeviceStatus getStatusOut() const;

		void setCreation(const time_t creation);
		time_t getCreation() const;

		void setUpdated(const time_t updated);
		time_t getUpdated() const;

		void setContacted(const time_t contacted);
		time_t getContacted() const;

		void setLastBackup(const time_t lastBackup);
		time_t getLastBackup() const;
		void updateLastBackup();

		void setLastRestore(const time_t lastRestore);
		time_t getLastRestore() const;
		void updateLastRestore();

		void setLocalChange(const time_t localChange);
		time_t getLocalChange() const;

		void setIp(const std::string& ip);
		std::string getIp() const;

		void setSHA(const std::string& SHA);
		std::string getSHA() const;

		void setName(const std::string& name);
		std::string getName() const;

		void setDescription(const std::string& description);
		std::string getDescription() const;

		void setActionPeriod(const std::string& actionPeriod);
		std::string getActionPeriod() const;
		bool onActionPeriod() const;

		void setConfigFileName(const std::string& configFileName);
		std::string getConfigFileName() const;

		void setCommands(const std::vector<Command>& commands);
		std::vector<Command> getCommands() const;

		void setBuild(const std::string& build);
		std::string getBuild() const;

		void setUpTime(const std::string& upTime);
		std::string getUpTime() const;

		void setRelease(const std::string& release);
		std::string getRelease() const;

		void setSwapUsed(const std::string& swapUsed);
		std::string getSwapUsed() const;

		void setMaxUsers(const std::string& maxUsers);
		std::string getMaxUsers() const;

		void setLicenseID(const std::string& licenseID);
		std::string getLicenseID() const;

		void setSystemLoad(const std::string& systemLoad);
		std::string getSystemLoad() const;

		void setGuiVersion(const std::string& guiVersion);
		std::string getGuiVersion() const;

		void setFreeMemory(const std::string& freeMemory);
		std::string getFreeMemory() const;

		void setPepsVersion(const std::string& pepsVersion);
		std::string getPepsVersion() const;

		void setCustomerName(const std::string& customerName);
		std::string getCustomerName() const;

		void setPartitionVar(const std::string& partitionVar);
		std::string getPartitionVar() const;

		void setPartitionRoot(const std::string& partitionRoot);
		std::string getPartitionRoot() const;

		void setPartitionHome(const std::string& partitionHome);
		std::string getPartitionHome() const;

		void setInstalledMemory(const std::string& installedMemory);
		std::string getInstalledMemory() const;

		void setHardwareDescription(const std::string& hardwareDescription);
		std::string getHardwareDescription() const;

		std::string toXML() const;
		std::string toXMLFull() const;
};

}

#endif
